/*
 * @Author : restyhap
 * @Date   : 2023-01-20 19:15:35
 * @LastEditors: restyhap
 * @LastEditTime: 2023-01-20 23:12:42
 */
const vscode = require("vscode");
const fs = require('fs');
const path = require('path');

/**
 * 清除所有的测试语句。
 * @param {vscode.TextEditor} textEditor 获取支持的当前文件对象
 */
function clearTab (textEditor) {
  let array = [];
  let doc = textEditor.document;
  let count = doc.lineCount;
  let suffixData = JSON.parse(fs.readFileSync(path.join(__dirname, "type.json"), { encoding: "utf8" })).data;
  for (let i = 0; i < count; i++) {
    let text = doc.lineAt(i).text;
    for (const o in suffixData) {
      const element = suffixData[o];
      if (text.includes(element.print.split("content")[0])) {
        array.push(i);
        break;
      }
    }
  }
  return array;
}

module.exports = {
  clearTab,
};
